<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class property_ctrl extends CI_Controller {

	
	function __construct(){
		parent::__construct();
		$this->load->model('property_mdl');
	}
	
	function Save(){
		if( !empty( $_POST ) ) {
			  $action = $this->input->post('action');
			  $id_properti=trim($this->input->post('id_properti'));              
			  $id_lokasi=trim($this->input->post('id_lokasi'));       
			  $jenis=trim($this->input->post('jenis'));       
			  $id_class=trim($this->input->post('id_class'));       
			  $harga_jual=$this->input->post('harga_jual');       
			  $luas_bangunan =$this->input->post('luas_bangunan');       
			  $luas_tanah=$this->input->post('luas_tanah');       
			  $tanah_hook=$this->input->post('tanah_hook');       
			  $jl_lantai=$this->input->post('jl_lantai');       
			  $arah_posisi =trim($this->input->post('arah_posisi'));       
			  $cluster=trim($this->input->post('cluster'));       
			  $nama_blok=trim($this->input->post('nama_blok'));       
			  $no_properti=$this->input->post('no_properti');       
			  $no_sertifikat=trim($this->input->post('no_sertifikat'));       
			  $jns_sertifikat=trim($this->input->post('jns_sertifikat'));       
			  $status=trim($this->input->post('status'));       
			  $rencana_tgl_mulai=$this->input->post('rencana_tgl_mulai');       
			  $rencana_tgl_selesai=$this->input->post('rencana_tgl_selesai');       
			  $aktual_tgl_mulai=$this->input->post('aktual_tgl_mulai');       
			  $aktual_tgl_selesai=$this->input->post('aktual_tgl_selesai');       
			  $progress_pembangunan=$this->input->post('progress_pembangunan');       
			  //$picture=$this->input->post('picture');       
			  $dt_stamp=$this->input->post('dt_stamp');       
			  $update_id=trim($this->input->post('update_id'));       
			
			  $data = array(
					 '$id_properti'=>$row->id_properti,
					 '$id_lokasi'=>$row->id_lokasi,
					 '$jenis'=>$row->jenis,
					 '$id_class'=>$row->id_class,
					 '$harga_jual'=>$row->harga_jual,
					 '$luas_bangunan'=>$row->luas_bangunan,
					 '$luas_tanah'=>$row->luas_tanah,
					 '$tanah_hook'=>$row->tanah_hook,
					 '$jl_lantai'=>$row->jl_lantai,
					 '$arah_posisi'=>$row->arah_posisi,   
					 '$cluster'=>$row->cluster,
					 '$nama_blok'=>$row->nama_blok, 
					 '$no_properti'=>$row->no_properti,
					 '$no_sertifikat'=>$row->no_sertifikat,
					 '$jns_sertifikat'=>$row->jns_sertifikat,
					 '$status'=>$row->status,
					 '$rencana_tgl_mulai'=>$row->rencana_tgl_mulai,
					 '$rencana_tgl_selesai'=>$row->rencana_tgl_selesai,
					 '$aktual_tgl_mulai'=>$row->aktual_tgl_mulai,
					 '$aktual_tgl_selesai'=>$row->aktual_tgl_selesai,
					 '$progress_pembangunan'=>$row->progress_pembangunan,
					 //'$picture'=>$row->picture,
					 '$dt_stamp'=>$row->dt_stamp,
					 '$update_id'=>$row->update_id
			);
			if ($action=="A"){
				$this->property_mdl->SaveAdd($data);
			} else {
				$this->property_mdl->SaveEdit($data);
				$data['view_data']=json_encode($this->property_mdl->getListProperty());
		    	$this->load->view('module/property_view',$data);
			}
			log_message('success', "property save successfully");
		}	
	}
	
	function Delete(){
		if( !empty( $_POST ) ) {
			$id_properti= trim($this->input->post('id_properti'));
			$id_lokasi= trim($this->input->post('id_lokasi'));
			$this->property_mdl->Delete($id_properti,$id_lokasi);
			$data['view_data']=json_encode($this->property_mdl->getListProperty());
		    $this->load->view('module/property_view',$data);
		}
			
	}
	
	function Refresh(){
		$data['view_data']=json_encode($this->property_mdl->getListProperty());
		$this->load->view('module/Property_view',$data);
	}
}